﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;

using FileTreeSpace;
using TravPresenterAbstraction;

namespace TravModelViewSpace
{
    public abstract class DetailModelView
    {
        private IDetailPresenter presenter;
        public IDetailPresenter Presenter
        {
            get { return presenter; }
            set
            {
                if (presenter != null)
                    throw new InvalidOperationException ("Detail presenter already assigned");

                presenter = value;
            }
        }

        public abstract TravModelView TravView { get; }

        public bool IsSubfoldersShown { get; internal set; }

        public event FileAddedEventHandler FileAdded;
        public void OnFileAdded (string newBaseName, long newSize, string newHash, string newPathName, DateTime dateModified, FileAttributes newAttrib)
        { if (FileAdded != null) FileAdded (newBaseName, newSize, newHash, newPathName, dateModified, newAttrib); }

        public event FileChangedEventHandler FileChanged;
        public void OnFileChanged (string fullName, long newSize, FileAttributes newAttributes)
        { if (FileChanged != null) FileChanged (fullName, newSize, newAttributes); }

        public event FileRenamedEventHandler FileRenamed;
        public void OnFileRenamed (string oldFullName, string newFullName, string newBaseName)
        { if (FileRenamed != null) FileRenamed (oldFullName, newFullName, newBaseName); }

        public event FileRemovedEventHandler FileRemoved;
        public void OnFileRemoved (string fullName) { if (FileRemoved != null) FileRemoved (fullName); }
    }
}
